home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / include / version_graph.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  5.4 KB  |  214 lines

  1. #ifndef _VERSION_GRAPH_H_
  2. #define _VERSION_GRAPH_H_
  3. /*
  4.  *   $RCSfile: version_graph.h,v $  
  5.  *   $Revision: 1.1.1.1 $  
  6.  *   $Date: 1996/05/04 21:55:09 $      
  7.  */ 
  8. #ifndef __VERSION_GRAPH_H__
  9. #define __VERSION_GRAPH_H__
  10.  
  11. /**********************************************************************
  12. * EXODUS Database Toolkit Software
  13. * Copyright (c) 1991 Computer Sciences Department, University of
  14. *                    Wisconsin -- Madison
  15. * All Rights Reserved.
  16. *
  17. * Permission to use, copy, modify and distribute this software and its
  18. * documentation is hereby granted, provided that both the copyright
  19. * notice and this permission notice appear in all copies of the
  20. * software, derivative works or modified versions, and any portions
  21. * thereof, and that both notices appear in supporting documentation.
  22. *
  23. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  24. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  25. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  26. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  27. *
  28. * The EXODUS Project Group requests users of this software to return 
  29. * any improvements or extensions that they make to:
  30. *
  31. *   EXODUS Project Group 
  32. *     c/o David J. DeWitt and Michael J. Carey
  33. *   Computer Sciences Department
  34. *   University of Wisconsin -- Madison
  35. *   Madison, WI 53706
  36. *
  37. *     or exodus@cs.wisc.edu
  38. *
  39. * In addition, the EXODUS Project Group requests that users grant the 
  40. * Computer Sciences Department rights to redistribute these changes.
  41. **********************************************************************/
  42. /*
  43.  * Declarations of various data structures used to for version history
  44.  * graphs (VHG's).
  45.  */
  46.  
  47. /*
  48.  * Version history graph node id.
  49.  */
  50. /* defined in ess.h */
  51.  
  52. /*
  53.  *    NULL VHG node id
  54.  */
  55. #define VHGNULLNODE    0xffffffff
  56.  
  57.  
  58. /*
  59.  *    This describes a "pointer" in a version history graph.  This
  60.  *     is an offset in bytes from beginning of the version graph.
  61.  */
  62. typedef FOUR VHGPTR ;
  63.  
  64. /*
  65.  * List header for lists of version history graph nodes
  66.  */
  67. typedef struct {
  68.     VHGPTR     succ;
  69.     VHGPTR    pred;
  70.     VHGPTR    item;
  71.     MAGIC                magic;
  72.  
  73. } VHGNODELIST;
  74.  
  75. /*
  76.  * Elements (links) in VHG node lists
  77.  */
  78. typedef VHGNODELIST     VHGNODELISTELEMENT;
  79.  
  80. /*
  81.  * Magic number for lists in version history graphs
  82.  */
  83. #define VHGLIST_MAGIC    0xa68f34c1
  84.  
  85.  
  86. /*
  87.  * Flags representing various states of a node
  88.  */
  89. typedef UONE VHGNODEFLAGS;
  90. #define    V_destroy_pending    0x1
  91. #define    V_frozen             0x2
  92. #define    V_tombstone            0x4
  93.  
  94.  
  95. /*
  96.  * VHG node
  97.  */
  98. typedef struct {
  99.     VHGNODEID            id;
  100.     VHGNODEID            parentId;
  101.     VHGNODELIST            children;
  102.     VHGNODELISTELEMENT  siblings;
  103.     OID                    oid;        /* object whose version is     */
  104.                                     /* represented by this node */
  105.      VHGNODEFLAGS        flags;        /* current state of node     */    
  106.     MAGIC                magic;
  107. } VHGNODE;
  108.  
  109.  
  110. /*
  111.  * Magic number for history graph nodes
  112.  */
  113. #define VHGNODE_MAGIC    0xd47a23b9
  114.  
  115. /*
  116.  * Initial starting size for the free list of nodes for a graph
  117.  */
  118. #define VHGINITSIZE 3
  119.  
  120.  
  121. /*
  122.  * Version history graph.
  123.  */
  124. typedef struct {
  125.     int            nodeCount;            /* current size of node array    */
  126.     VHGNODEID    root;                /* root of the graph             */
  127.     VHGNODELIST    freeList;            /* list of free nodes            */
  128.     MAGIC                magic;
  129.     VHGNODE        nodeArray[VHGINITSIZE];    /* variable length array    */
  130. } VERSIONGRAPH;
  131.  
  132. /*
  133.  * Magic number for version history graphs
  134.  */
  135. #define VERSIONGRAPH_MAGIC    0x3d2da41b
  136.  
  137.  
  138. /********************************************************************/
  139.  
  140. /*
  141.  *    VHG Macros
  142.  */
  143.  
  144. /*
  145.  * Header properties macros
  146.  */
  147. #define WORKING_VERSION(_properties)                                 \
  148.     ( (_properties & P_VERSIONED) && !(_properties & P_FROZEN) )
  149.  
  150. /*
  151.  *     Null VHG pointers
  152.  */
  153. #define VHGPTR_SET_NULL(_vhgPtr)                                    \
  154.     (_vhgPtr)->oid.diskAddr.volid = 0;
  155.  
  156. #define VHGPTR_IS_NULL(_vhgPtr)                                        \
  157.     ((_vhgPtr)->oid.diskAddr.volid == 0)
  158.  
  159. /*
  160.  *  define the magic checking macros
  161.  */
  162.  
  163. #if MAGIC_CHECKING IS_ENABLED
  164.  
  165.  
  166. #define INIT_VHGNODE_MAGIC(_vhgNode)                        \
  167.                                                             \
  168.     (_vhgNode)->magic = VHGNODE_MAGIC;
  169.  
  170. #define INIT_VERSIONGRAPH_MAGIC(_versionGraph)              \
  171.                                                             \
  172.     (_versionGraph)->magic = VERSIONGRAPH_MAGIC;
  173.  
  174. #define INIT_VHGLIST_MAGIC(_vhgList)              \
  175.                                                             \
  176.     (_vhgList)->magic = VHGLIST_MAGIC;
  177.  
  178.  
  179. #define CHECK_VHGNODE_MAGIC(_vhgNode)                         \
  180.                                                             \
  181.     if ((_vhgNode)->magic != VHGNODE_MAGIC)   {               \
  182.                                                             \
  183.         SM_ERROR(TYPE_FATAL, esmINTERNAL);                  \
  184.     }
  185.  
  186. #define CHECK_VERSIONGRAPH_MAGIC(_versionGraph)            \
  187.                                                             \
  188.     if ((_versionGraph)->magic != VERSIONGRAPH_MAGIC)   {  \
  189.                                                             \
  190.         SM_ERROR(TYPE_FATAL, esmINTERNAL);                  \
  191.     }
  192.  
  193. #define CHECK_VHGLIST_MAGIC(_vhgList)            \
  194.                                                             \
  195.     if ((_vhgList)->magic != VHGLIST_MAGIC)   {  \
  196.                                                             \
  197.         SM_ERROR(TYPE_FATAL, esmINTERNAL);                  \
  198.     }
  199.  
  200.  
  201. #else
  202.  
  203. #define INIT_VHGNODE_MAGIC(x)
  204. #define INIT_VERSIONGRAPH_MAGIC(x)
  205. #define INIT_VHGLIST_MAGIC(x)
  206.  
  207. #define CHECK_VHGNODE_MAGIC(x)
  208. #define CHECK_VERSIONGRAPH_MAGIC(x)
  209. #define CHECK_VHGLIST_MAGIC(x)
  210.  
  211. #endif
  212. #endif __VERSION_GRAPH_H__
  213. #endif /* _VERSION_GRAPH_H_ */
  214.